package rad.framework.mda.generator.template.main.webapp.webinf;

import java.util.*;
import rad.framework.mda.generator.util.*;
import org.eclipse.uml2.uml.*;

public class JsfPages
{
  protected static String nl;
  public static synchronized JsfPages create(String lineSeparator)
  {
    nl = lineSeparator;
    JsfPages result = new JsfPages();
    nl = null;
    return result;
  }

  public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
  protected final String TEXT_1 = "<pages>";
  protected final String TEXT_2 = NL + NL + "\t<!-- ";
  protected final String TEXT_3 = " -->" + NL + "\t" + NL + "\t<page view-id=\"/jsf/";
  protected final String TEXT_4 = "/Edit.xhtml\" login-required=\"true\"" + NL + "\t\taction=\"#{";
  protected final String TEXT_5 = "Editor.init";
  protected final String TEXT_6 = "Tree}\">" + NL + "\t\t<begin-conversation join=\"true\" flush-mode=\"MANUAL\" />" + NL + "\t\t<rewrite pattern=\"/";
  protected final String TEXT_7 = "/edit/{id}\" />" + NL + "\t\t<rewrite pattern=\"/";
  protected final String TEXT_8 = "/edit\" />" + NL + "\t\t<restrict>#{s:hasRole('User')}</restrict>" + NL + "\t\t<param name=\"id\" value=\"#{";
  protected final String TEXT_9 = "Editor.requestedId}\"/>\t" + NL + "\t\t<description>#{messages['";
  protected final String TEXT_10 = "']} : #{";
  protected final String TEXT_11 = "Tree.master.text}</description>" + NL + "\t</page>" + NL + "\t<page view-id=\"/jsf/";
  protected final String TEXT_12 = "/View.xhtml\" login-required=\"true\"" + NL + "\t\taction=\"#{";
  protected final String TEXT_13 = "Editor.init";
  protected final String TEXT_14 = "Tree}\">" + NL + "\t\t<begin-conversation join=\"true\" flush-mode=\"MANUAL\" />" + NL + "\t\t<rewrite pattern=\"/";
  protected final String TEXT_15 = "/{id}\" />" + NL + "\t\t<restrict>#{s:hasRole('User')}</restrict>" + NL + "\t\t<param name=\"id\" value=\"#{";
  protected final String TEXT_16 = "Editor.requestedId}\"/>\t" + NL + "\t\t<description>#{messages['";
  protected final String TEXT_17 = "']} : #{";
  protected final String TEXT_18 = "Tree.master.text}</description>" + NL + "\t</page>" + NL + "\t<page view-id=\"/jsf/";
  protected final String TEXT_19 = "/Search.xhtml\" login-required=\"true\">" + NL + "\t\t<rewrite pattern=\"/";
  protected final String TEXT_20 = "Search\" />" + NL + "\t\t<restrict>#{s:hasRole('User')}</restrict>" + NL + "\t</page>" + NL + "\t<page view-id=\"/jsf/";
  protected final String TEXT_21 = "/Charts.xhtml\" login-required=\"true\">" + NL + "\t\t<rewrite pattern=\"/";
  protected final String TEXT_22 = "Charts\" />" + NL + "\t\t<restrict>#{s:hasRole('User')}</restrict>" + NL + "\t</page>" + NL + "\t<page view-id=\"/pdf/";
  protected final String TEXT_23 = "/";
  protected final String TEXT_24 = ".xhtml\" login-required=\"true\"" + NL + "\t\taction=\"#{";
  protected final String TEXT_25 = "Editor.init";
  protected final String TEXT_26 = "Tree}\">" + NL + "\t\t<rewrite pattern=\"/pdf/";
  protected final String TEXT_27 = "\" />" + NL + "\t\t<restrict>#{s:hasRole('User')}</restrict>" + NL + "\t\t<param name=\"id\" value=\"#{";
  protected final String TEXT_28 = "Editor.requestedId}\"/>\t" + NL + "\t</page>" + NL + "\t<page view-id=\"/pdf/";
  protected final String TEXT_29 = "/";
  protected final String TEXT_30 = "List.xhtml\" login-required=\"true\">" + NL + "\t\t<rewrite pattern=\"/pdf/";
  protected final String TEXT_31 = "List\" />" + NL + "\t\t<restrict>#{s:hasRole('User')}</restrict>" + NL + "\t</page>" + NL + "\t<page view-id=\"/xls/";
  protected final String TEXT_32 = "/";
  protected final String TEXT_33 = ".xhtml\" login-required=\"true\">" + NL + "\t\t<rewrite pattern=\"/xls/";
  protected final String TEXT_34 = "\" />" + NL + "\t\t<restrict>#{s:hasRole('User')}</restrict>" + NL + "\t</page>";
  protected final String TEXT_35 = NL + "\t" + NL + "\t<!-- Pageflow Navigation -->";
  protected final String TEXT_36 = NL + NL + "\t<page view-id=\"/jsf/";
  protected final String TEXT_37 = "/Pageflow.xhtml\" login-required=\"true\">" + NL + "\t\t<rewrite pattern=\"/";
  protected final String TEXT_38 = "\" />" + NL + "\t\t<restrict>#{s:hasRole('User')}</restrict>" + NL + "\t\t<description>#{messages['";
  protected final String TEXT_39 = "']}</description>" + NL + "\t</page>";
  protected final String TEXT_40 = NL + "\t" + NL + "</pages>";

  public String generate(Object argument)
  {
    final StringBuffer stringBuffer = new StringBuffer();
    

    Model uml2Model = (Model) argument;
    stringBuffer.append(TEXT_1);
    for (Iterator i=ClassHelper.getClasses(uml2Model).iterator(); i.hasNext();) { org.eclipse.uml2.uml.Class element = (org.eclipse.uml2.uml.Class)i.next();
    if (!ClassHelper.hasSubclasses(element) && StereotypeHelper.isStereotypeApplied(element,"javax.persistence.Entity")) {
    stringBuffer.append(TEXT_2);
    stringBuffer.append(element.getName());
    stringBuffer.append(TEXT_3);
    stringBuffer.append(element.getName());
    stringBuffer.append(TEXT_4);
    stringBuffer.append(NameHelper.getUncapName(element));
    stringBuffer.append(TEXT_5);
    stringBuffer.append(element.getName());
    stringBuffer.append(TEXT_6);
    stringBuffer.append(element.getName());
    stringBuffer.append(TEXT_7);
    stringBuffer.append(element.getName());
    stringBuffer.append(TEXT_8);
    stringBuffer.append(NameHelper.getUncapName(element));
    stringBuffer.append(TEXT_9);
    stringBuffer.append(element.getName());
    stringBuffer.append(TEXT_10);
    stringBuffer.append(NameHelper.getUncapName(element));
    stringBuffer.append(TEXT_11);
    stringBuffer.append(element.getName());
    stringBuffer.append(TEXT_12);
    stringBuffer.append(NameHelper.getUncapName(element));
    stringBuffer.append(TEXT_13);
    stringBuffer.append(element.getName());
    stringBuffer.append(TEXT_14);
    stringBuffer.append(element.getName());
    stringBuffer.append(TEXT_15);
    stringBuffer.append(NameHelper.getUncapName(element));
    stringBuffer.append(TEXT_16);
    stringBuffer.append(element.getName());
    stringBuffer.append(TEXT_17);
    stringBuffer.append(NameHelper.getUncapName(element));
    stringBuffer.append(TEXT_18);
    stringBuffer.append(element.getName());
    stringBuffer.append(TEXT_19);
    stringBuffer.append(element.getName());
    stringBuffer.append(TEXT_20);
    stringBuffer.append(element.getName());
    stringBuffer.append(TEXT_21);
    stringBuffer.append(element.getName());
    stringBuffer.append(TEXT_22);
    stringBuffer.append(element.getName());
    stringBuffer.append(TEXT_23);
    stringBuffer.append(element.getName());
    stringBuffer.append(TEXT_24);
    stringBuffer.append(NameHelper.getUncapName(element));
    stringBuffer.append(TEXT_25);
    stringBuffer.append(element.getName());
    stringBuffer.append(TEXT_26);
    stringBuffer.append(element.getName());
    stringBuffer.append(TEXT_27);
    stringBuffer.append(NameHelper.getUncapName(element));
    stringBuffer.append(TEXT_28);
    stringBuffer.append(element.getName());
    stringBuffer.append(TEXT_29);
    stringBuffer.append(element.getName());
    stringBuffer.append(TEXT_30);
    stringBuffer.append(element.getName());
    stringBuffer.append(TEXT_31);
    stringBuffer.append(element.getName());
    stringBuffer.append(TEXT_32);
    stringBuffer.append(element.getName());
    stringBuffer.append(TEXT_33);
    stringBuffer.append(element.getName());
    stringBuffer.append(TEXT_34);
    }}
    stringBuffer.append(TEXT_35);
    for (Iterator<Region> i=JsfHelper.getPageflows(uml2Model); i.hasNext();) { Region region = (Region)i.next();
    stringBuffer.append(TEXT_36);
    stringBuffer.append(NameHelper.removeSpaces(region.getName()));
    stringBuffer.append(TEXT_37);
    stringBuffer.append(NameHelper.removeSpaces(region.getName()));
    stringBuffer.append(TEXT_38);
    stringBuffer.append(NameHelper.removeSpaces(region.getName()));
    stringBuffer.append(TEXT_39);
    }
    stringBuffer.append(TEXT_40);
    return stringBuffer.toString();
  }
}
